package com.hubei.control;

import com.hubei.service.UserService;
import com.hubei.vo.Users;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;

/**
 * @author PJM
 * @date 2025/6/24-14:27
 */
@WebServlet("/user_list.action")
public class UserListControl extends HttpServlet {

    private UserService service = UserService.getInstance();

    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        // 获取客户端发送过来的参数
        request.setCharacterEncoding("UTF-8");
        String username = request.getParameter("username");
        List<Users> userList = service.queryUserList(username);
        request.setAttribute("userList", userList);
        request.setAttribute("username", username);
        request.getRequestDispatcher("./user_list.jsp").forward(request,response);
    }

    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        doPost(request, response);
    }
}
